package breeze.pixel.weather.earthquake.view;

import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;

import breeze.pixel.weather.BaseView;
import breeze.pixel.weather.R;
import breeze.pixel.weather.apps_util.views.mtextview.MTextView;
import brz.breeze.tool_utils.Blog;

public class EarthquakeDataActivity extends BaseView {
    
    public static String TAG = EarthquakeDataActivity.class.getSimpleName();
    
    private String time,situated,longitude,deep,level,area;
    
    private MTextView earthquake_location;
    private MTextView earthquake_time;
    private MTextView earthquake_situated;
    private MTextView earthquack_longitude;
    private MTextView earthquake_level;
    private MTextView earthquake_deep;
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.M){
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
        }
        getWindow().setStatusBarColor(Color.WHITE);
        setContentView(R.layout.activity_earthquake_info);
        if(getActionBar()!=null){
            getActionBar().hide();
        }
        Intent intent=getIntent();
        if(intent!=null){
            time=intent.getStringExtra("time");
            situated=intent.getStringExtra("situated");
            longitude=intent.getStringExtra("longitude");
            deep=intent.getStringExtra("deep");
            level=intent.getStringExtra("level");
            area=intent.getStringExtra("location");
            Blog.i(TAG,area);
        }
        //初始化控件
        init();
        //设置文本
        initData();
    }

    @Override
    public void init() {
        earthquake_location = findViewById(R.id.earthquake_location);
        earthquake_time = findViewById(R.id.earthquake_time);
        earthquake_situated = findViewById(R.id.earthquake_situated);
        earthquack_longitude = findViewById(R.id.earthquack_longitude);
        earthquake_level = findViewById(R.id.earthquake_level);
        earthquake_deep = findViewById(R.id.earthquake_deep);
    }

    @Override
    public void initData() {
        try
        {
            earthquake_deep.setText(String.format("深度：%s", deep));
            earthquack_longitude.setText(String.format("经度：%s", longitude));
            earthquake_level.setText(String.format("震级：%s", level));
            earthquake_location.setText(area);
            earthquake_situated.setText(String.format("纬度：%s", situated));
            earthquake_time.setText(time);
        }catch(Exception e)
        {
            toast("获取数据失败");
        }
    }
    
}
